package com.lintcode.solution;

public class Solution_517 {
    public static void main(String[] args) {
        int n = 8;
        System.out.println(isUgly(n));
    }
    
    public static boolean isUgly(int num) {
        if (num == 2 || num == 3 || num == 5 || num == 1) {
            return true;
        }
        if (num == 0) {
            return false;
        }
        if (num % 5 == 0) {
            return isUgly(num / 5);
        }
        if (num % 3 == 0) {
            return isUgly(num / 3);
        }
        if (num % 2 == 0) {
            return isUgly(num / 2);
        }
        return false;
    }
}
